package dfsketches.gr3d;

public class WanderingPlayer extends Player {
	private Vector3D pos;
	private World world;
	private MovableObject mob;
	private PolarCamera view;

	public WanderingPlayer(PolarCamera cam, Vector3D pos, float facingAngle,
			World w, MovableObject movable) {
		super(cam, pos, facingAngle);
		this.pos = new Vector3D(pos);
		world = w;
		mob = movable;
		view = cam;
		move(new Vector3D(0f,0f,0f));
	}
	
	public void moveForward() {
		move(new Vector3D(0f, 0f, 1f));
	}
	
	public void moveBackward() {
		move(new Vector3D(0f, 0f,-1f));
	}
	
	public void moveLeft() {
		move(new Vector3D( 1f, 0f, 0f));
	}
	
	public void moveRight() {
		move(new Vector3D(-1f, 0f, 0f));
	}
	
	public void zoomIn() {
		view.setDistance(view.getDistance() / 1.1f);
	}
	
	public void zoomOut() {
		view.setDistance(view.getDistance() * 1.1f);
	}
	
	public void turnDown() {
		super.turnUp();
	}
	
	public void turnUp() {
		super.turnDown();
	}
	
	private void move(Vector3D dir) {
		dir.apply(Matrix3D.getRotationYMatrix(angleY));
		pos.add(dir);
		pos = world.getGeodata().drop(pos);
		mob.moveTo(pos);
//		pos.add(new Vector3D(0f, 2f, 0f));
		view.setPosition(pos);
	}

}